#include<iostream>
#include<cctype>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cmath>
#define N 1000
#define M 110000
#define inf 1e9+7
#define ll long long
using namespace std;
inline int read()
{
    int x=0,flag=1;
    char ch=0;
    while(!isdigit(ch)){ch=getchar();if(ch=='-')flag=-1;}
    while(isdigit(ch)) {x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*flag;
}
int ans1=inf,ans2=-inf,a[N],pre[N],f[N][N],g[N][N],dp[N][N];
void solve(int nn)
{
	int n=2*nn;
	memset(f,0,sizeof(f));
	memset(g,0,sizeof(g));
	for(int i=1;i<=n;i++)dp[i][i]=0,g[i][i]=i;
	for(int len=2;len<=nn;len++)
	for(int i=1;i+len-1<=n;i++)
	{
		int l=i,r=i+len-1;
		dp[l][r]=inf;
		
		for(int k=g[l][r-1];k<=g[l+1][r];k++)
		{
			int x=dp[l][k]+dp[k+1][r]+pre[r]-pre[l-1];
			if(dp[l][r]>x)g[l][r]=k,dp[l][r]=x;
		}

	}
	ans1=inf;
	for(int i=1;i<=nn;i++)ans1=min(ans1,dp[i][i+nn-1]);
}

int main()
{
    int n,i,j,k;
    n=read();
    for(i=1;i<=n;i++)
    a[i]=a[i+n]=read();
    for(i=1;i<=2*n;i++)
    pre[i]=pre[i-1]+a[i];
    for(i=2*n-1;i>=1;i--)
      for(j=i+1;j<=i+n-1;j++)
      {
          f[i][j]=inf;
          g[i][j]=-inf;
          for(k=i;k<=j-1;k++)
          {
              f[i][j]=min(f[i][j], f[i][k]+f[k+1][j]+pre[j]-pre[i-1]);
              g[i][j]=max(g[i][j], g[i][k]+g[k+1][j]+pre[j]-pre[i-1]);
          }
      }
    for(i=1;i<=n;i++)
    {
        ans1=min(ans1,f[i][i+n-1]);
        ans2=max(ans2,g[i][i+n-1]);
    }
    solve(n); 
	cout<<ans1<<endl<<ans2;
    return 0;
}
